package org.mijia.dotsbox.core;

import java.util.List;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.mijia.dotsbox.core.model.Channel;

public class ChannelDao extends BaseDao<Channel, String> {

	public ChannelDao() {
		super(Channel.class);
	}
	
	public List<String> findByFolderId(String folderId) {
		Query pidTerm = new TermQuery(new Term("parentId", folderId));
		Query clazzTerm = new TermQuery(new Term("clazz", Channel.class.getName()));
		BooleanQuery query = new BooleanQuery();
		query.add(pidTerm, BooleanClause.Occur.MUST);
		query.add(clazzTerm, BooleanClause.Occur.MUST);
		
		List<String> ids = getEntityManager().getIds(query, null);
		return ids;
	}
}
